import request from '../../utils/request'

/**
 * 分页查询费用列表
 *
 * @param id
 * @param status
 * @param page
 * @returns {Promise.<Object>}
 */
export async function queryOrderCost({ orderId, status, page }) {
    return request(apiPath.mc + "/api/ordercharges", {
        method: 'GET',
        data: { orderId, status, page: page.page, size: page.size }
    });
}

/**
 * 添加费用
 *
 * @param id
 * @returns {Promise.<Object>}
 */
export async function addOrderCost({ orderId, data }) {
    return request(apiPath.mc + "/api/order/" + orderId + "/ordercharge", {
        method: 'POST',
        data: data
    });
}

/**
 * 删除费用
 *
 * @param id
 * @returns {Promise.<Object>}
 */
export async function deleteOrderCost({ id }) {
    return request(apiPath.mc + "/api/ordercharge/" + id, {
        method: 'DELETE',
    });
}

/**
 * 申报/审批 费用
 *
 * @param id
 * @returns {Promise.<Object>}
 */
export async function applyOrderCost({ data }) {
    return request(apiPath.mc + "/api/ordercharge/apply", {
        method: 'PUT',
        data
    });
}

/**
 * 确认费用收齐
 *
 * @param id
 * @param chargeStatus {1: 通关收齐, 2:跟单收齐}
 * @returns {Promise.<Object>}
 */
export async function confirmCost({ id, chargeStatus }) {
    return request(apiPath.mc + "/api/order/" + id + "/collectedordercharge", {
        method: 'PUT',
        data: { chargeStatus }
    });
}